home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1995 #5 & #6 / Amiga Plus CD - 1995 - No. 5 and 6.iso / pd / daten / quickfile / arexx / delrecs.quickfile < prev    next >
Text File  |  1995-04-06  |  2KB  |  84 lines

  1. /*
  2.     DeleteRecs.QuickFile
  3.  
  4.     Deletes all records in the current index (hopefully a selection)
  5.     Asks for confirmation before it alters the file
  6.  
  7.     Run this from the 'Options/Arexx macro' menu item
  8.     Author: Alan Wigginton
  9.     Date:   March 1995
  10. */
  11.  
  12. options results
  13.  
  14. if ~open(console,"con:20/40/460/120/SetField","W") then
  15. do
  16.     say "Could not open window"
  17.     exit(20)
  18. end
  19.  
  20. "setindex"              /* get the current index name   */
  21. ixname = result
  22.  
  23. "query index ixfld '"ixname"'"  /* get the index field names    */
  24. if rc > 0 then
  25.     call ErrorProc "Error getting index details"
  26.  
  27. call writeln(console, "Mass delete of records")
  28. call writeln(console, "- deletes all records in the current index")
  29. /*
  30.     Confirm operation and number of records to be deleted
  31. */
  32.  
  33. "numrecs"       /* ask quickfile for the number of records */
  34. numrecs = result
  35.  
  36. call writeln(console, "About to delete" numrecs "records")
  37. call writeln(console, "Enter Y to continue")
  38. ans = upper(readln(console))
  39. if ans ~= "Y" then
  40. do
  41.     call writeln(console, "Request cancelled - press any key")
  42.     ans = readln(console)
  43.     exit
  44. end
  45.  
  46. "next -32000"       /* This goes to top of file */
  47.  
  48. /*
  49.     Delete the records
  50. */
  51.  
  52. do count = 1 to numrecs
  53.     "delrec"
  54.     if rc > 0 then
  55.     do
  56.     call writeln(console, "Error from DelRec after")
  57.     call ErrorProc count "records deleted"
  58.     end
  59. end
  60.  
  61. /*
  62.     Tell the user that we completed it OK
  63. */
  64.  
  65. call writeln(console, numrecs "records deleted")
  66. call writeln(console, "Press RETURN to continue")
  67. ans = readln(console)
  68. exit
  69.  
  70. /*
  71.     Display error message and exit
  72.     ------------------------------
  73. */
  74.  
  75. ErrorProc:
  76.  
  77. arg errmsg
  78.  
  79. call writeln(console, errmsg)
  80. call writeln(console, "Press RETURN to continue")
  81. ans = readln(console)
  82. exit(10)
  83.  
  84.